package com.example.t211109;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    //声明控件
    private Button btn;
    private EditText edtUserName,edtName,edtEmail,edtPhone,edtPassword,edtPassword2;
    private Spinner spinnerCollege,spinnerMajor;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        //找到控件
        btn=findViewById(R.id.btn_register);
        edtUserName =findViewById(R.id.edt_userName);
        edtName=findViewById(R.id.edt_name);
        edtEmail=findViewById(R.id.edt_email);
        edtPhone=findViewById(R.id.edt_phone);
        edtPassword=findViewById(R.id.edt_password);
        edtPassword2=findViewById(R.id.edt_password2);
        spinnerCollege=findViewById(R.id.spinner_college);
        spinnerMajor=findViewById(R.id.spinner_major);


        //点击事件
        btn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "用户名：" + edtUserName.getText().toString() + "   ,真实姓名：" + edtName.getText().toString() +
                        "   ,邮箱：" + edtEmail.getText().toString() + "   ,电话：" + edtPhone.getText().toString() +"   ，就读部门："+spinnerCollege.getSelectedItem().toString()
                        +"   ，就读专业："+spinnerMajor.getSelectedItem().toString()+ "   ,密码："+ edtPassword.getText().toString(), Toast.LENGTH_LONG).show();
            }
        });
    }
}